package jobPerCity;

import Bean.JobPerCityBean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;

public class JobPerCityMapper extends Mapper<Object, Text, Text, JobPerCityBean> {
    private Text outputKey = new Text();

    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        String[] fields = value.toString().split(",");


        String city = fields[7];
        String jobType = fields[3];


        if (city.equals("city")){
            return;
        }

        JobPerCityBean bean = new JobPerCityBean(city, jobType);

        outputKey.set(city);
        context.write(outputKey, bean);

    }
}